import './style.scss'
class Loading {

  constructor() {
    this.initLoading();
  }
  initLoading(){
    // 创建一个loading 盒子 添加到 body上
    // 全屏的遮罩层
   const loadingContainer = document.createElement('div');
   loadingContainer.classList.add('loadingContainer');
   // loading盒子
   const loadingBox = document.createElement('div');
   loadingBox.className="loadingBox";
   loadingContainer.appendChild(loadingBox);
   document.body.appendChild(loadingContainer);
    //  添加到实例上
    this.loadingContainer = loadingContainer;
  };
  showLoading(){
    this.loadingContainer.classList.add('active');
  };
  hideLoading(){
    this.loadingContainer.classList.remove('active');
  }
  static getInstance() {
      if (!Loading._instance) {
        Loading._instance = new Loading()
      }
      return Loading._instance
  }
}


export default Loading